package com.murray.assignment.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.murray.assignment.mapper.GoodsMapper;
import com.murray.assignment.pojo.Goods;
import com.murray.assignment.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Murray
 * @Date 2021/6/13
 * @Time 13:38
 */
@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public PageInfo<Goods> findGoodsByCid(Integer cid, Integer presentPage, Integer pageSize) {
        /*
        开启分页插件，
         */
        PageHelper.startPage(presentPage, pageSize);
        List<Goods> goodsList = goodsMapper.findGoodsByCid(cid);
        PageInfo<Goods> pageInfo = new PageInfo<>(goodsList);
        return pageInfo;
    }

    @Override
    public Goods selectByGoodsId(Integer goodsId) {
        return goodsMapper.selectByGoodsId(goodsId);
    }
}
